from Fun import *
from threading import Thread
from multiprocessing import Process
import time

if __name__ == "__main__":
    st = time.time()
    for i in range(10):
        count(1, 1)
    print('Single cpu:', time.time() - st)
    st = time.time()
    for i in range(10):
        io()
    print('Single IO:', time.time() - st)

    jobs = []
    st = time.time()
    for i in range(10):
        t = Thread(target=count, args=(1, 1))
        jobs.append(t)
        t.start()

    for i in jobs:
        i.join()
    print('Thread cpu:', time.time() - st)


    jobs = []
    st = time.time()
    for i in range(10):
        t = Thread(target=io)
        jobs.append(t)
        t.start()

    for i in jobs:
        i.join()
    print('Thread io:', time.time() - st)


    jobs = []
    st = time.time()
    for i in range(10):
        t = Process(target=count, args=(1, 1))
        jobs.append(t)
        t.start()

    for i in jobs:
        i.join()
    print('Process cpu:', time.time() - st)


    jobs = []
    st = time.time()
    for i in range(10):
        t = Process(target=io)
        jobs.append(t)
        t.start()

    for i in jobs:
        i.join()
    print('Process io:', time.time() - st)
